pre>+ func getContentView() -> UIView? { 86
+        for v in subviews {
87
+            if let ContentClass = NSClassFromString("_UINavigationBarContentView"), v.isKind(of: ContentClass) {
88
+                return v
89
+            }
90
+        }
91
+        return nil
92
+    }
93
+    
94
+    func getShadowView() -> UIView? {
95
+        guard let barBackground = getBarBackground() else { return nil }
96
+        for v in barBackground.subviews {
97
+            if (v.bounds.height == 0.5) {
98
+                return v
99
+            }
100
+        }
101
+        return nil
102
+    }
103
+    
104
+    func getNavigationBarBounds() -> CGRect {
105
+        let statusHeight = UIApplication.shared.statusBarFrame.height
106
+        return CGRect(x: 0, y: -statusHeight, width: bounds.width, height: bounds.height + statusHeight)
107
+    }
108
+    
109
+    override func value(forUndefinedKey key: String) -> Any? {
110
+        return nil
111
+    }
112
+}
113
+
114
+/// NavigationBar transition
115
+extension NavigationBar {
116
+    func constructViewHierarchy() {
117
+        setupShadowView()
118
+        setupBackgroundImageView()
119
+        
120
+        guard let barBackground = getBarBackground() else { return }
121
+        
122
+        insertSubview(shadowImageView, aboveSubview: barBackground)
123
+        insertSubview(backgroundImageView, aboveSubview: barBackground)
124
+        insertSubview(fakeView, belowSubview: backgroundImageView)
125
+        layoutIfNeeded()
126
+    }
127
+    
128
+    private func setupShadowView() {
129
+        if let image = originShadowImage, image.size == CGSize.zero {
130
+            shadowImageView.image = image
131
+        } else {
132
+            shadowImageView.backgroundColor = UIColor(red: 0, green: 0, blue: 0,
133
+                                                      alpha: 77.0 / 255)
134
+        }
135
+        
136
+        shadowImageView.alpha = originShadowImage == nil ? 1 : 0
137
+        getShadowView()?.isHidden = true
138
+    }
139
+    
140
+    private func setupBackgroundImageView() {
141
+        if isPush {
142
+            fakeView.alpha = 0
143
+            backgroundImageView.image = targetBgImage
144
+        } else {
145
+            setBackgroundImage()
146
+            fakeView.alpha = 1
147
+            backgroundImageView.image = currBgImage
148
+        }
149
+    }
150
+    
151
+    /// interactivePopGestureRecognizer
152
+    func transitionAnimationWithPercent(_ percent: CGFloat) {
153
+        switch bounce {
154
+        case .forward, .none:
155
+            transitionShadowAnimationWithPercent(percent)
156
+            transitionBackgroundAnimationWithPercent(percent)
157
+            break
158
+        case .backward:
159
+            transitionShadowAnimationWithPercent(1 - percent)
160
+            transitionBackgroundAnimationWithPercent(1 - percent)
161
+            break
162
+        }
163
+    }
164
+    
165
+    func transitionAnimation() {
166
+        transitionShadowAnimation()
167
+        transitionBackgroundAnimation()
168
+    }
169
+    
170
+    private func transitionShadowAnimation() {
171
+        guard hasChangedShadow else { return }
172
+        shadowImageView.alpha = originShadowImage == nil ? 0 : 1
173
+//        if originShadowImage == nil {
174
+//            shadowImageView.alpha = isInteractive ? (1 - percent) * 1 : 0
175
+//        } else {
176
+//            shadowImageView.alpha = isInteractive ? percent * 1 : 1
177
+//        }
178
+    }
179
+    
180
+    private func transitionBackgroundAnimation() {
181
+        guard hasChangedBgImage else { return }
182
+        if isPush {
183
+            fakeView.alpha = 1
184
+            backgroundImageView.frame.origin.x = 0
185
+        } else {
186
+            fakeView.alpha = 0
187
+            backgroundImageView.frame.origin.x = bounds.width
188
+        }
189
+    }
190
+    
191
+    private func transitionShadowAnimationWithPercent(_ percent: CGFloat) {
192
+        guard hasChangedShadow else { return }
193
+        shadowImageView.alpha = originShadowImage == nil ? (1 - percent) * 1 : percent * 1
194
+    }
195
+    
196
+    private func transitionBackgroundAnimationWithPercent(_ percent: CGFloat) {
197
+        guard hasChangedBgImage else { return }
198
+        fakeView.alpha = (1 - percent) * 1
199
+        backgroundImageView.frame.origin.x = percent * bounds.width
200
+    }
201
+    
202
+    func clear() {
203
+        
204
+        if isPush && hasChangedBgImage { setBackgroundImage() }
205
+        
206
+        if !isPush && bounce == .backward && hasChangedBgImage {
207
+            targetBgImage = currBgImage
208
+            setBackgroundImage()
209
+        }
210
+        
211
+        getShadowView()?.isHidden = false
212
+        
213
+        fakeView.removeFromSuperview()
214
+        shadowImageView.removeFromSuperview()
215
+        backgroundImageView.removeFromSuperview()
216
+        
217
+        currBgImage = nil
218
+        targetBgImage = nil
219
+        
220
+        hasChangedBgImage = false
221
+        hasChangedShadow = false
222
+        
223
+        bounce = .none
224
+    }
225
+}
226
+
227
+extension NavigationBar {
228
+    enum Bounce {
229
+        case none
230
+        case backward
231
+        case forward
232
+    }
233
+}

+ 100 - 18
PaiAi/PaiaiUIKit/Reusable/UIKit/NavigationController/NavigationController.swift

@@ -2,28 +2,110 @@
2 2
 //  NavigationController.swift
3 3
 //  PaiaiUIKit
4 4
 //
5
-//  Created by ffib on 2019/4/3.
6
-//  Copyright © 2019 yb. All rights reserved.
5
+//  Created by ffib on 2019/4/23.
6
+//  Copyright © 2019 FFIB. All rights reserved.
7 7
 //
8 8
 
9 9
 import UIKit
10 10
 
11
-class NavigationController: UINavigationController {
11
+public class NavigationController: UINavigationController {
12 12
     
13
+    override public init(rootViewController: UIViewController) {
14
+        super.init(navigationBarClass: NavigationBar.classForCoder(), toolbarClass: nil)
15
+//        super.init(rootViewController: rootViewController)
16
+//        navigationBar.delegate = self
17
+        self.viewControllers = [rootViewController]
18
+    }
19
+    
20
+    required init?(coder aDecoder: NSCoder) {
21
+        super.init(coder: aDecoder)
22
+    }
23
+    
24
+    override public init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
25
+        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
26
+    }
27
+    
28
+    override public func viewDidLoad() {
29
+        super.viewDidLoad()
30
+        delegate = self
31
+        interactivePopGestureRecognizer?.delegate = self
32
+        interactivePopGestureRecognizer?.isEnabled = true
33
+        
34
+        
35
+        interactivePopGestureRecognizer?.addTarget(self,
36
+                                                   action: #selector(handlePop(gestureRecognizer:)))
37
+    }
38
+    
39
+    @objc
40
+    private func handlePop(gestureRecognizer: UIPanGestureRecognizer) {
41
+        guard let navBar = navigationBar as? NavigationBar else { return }
42
+        if gestureRecognizer.state == .began { navBar.isPush = false }
43
+        
44
+        guard navBar.needsInteractive else { return }
45
+        
46
+        let percent = gestureRecognizer.translation(in: view).x / view.bounds.width
47
+        
48
+        if gestureRecognizer.state == .began || gestureRecognizer.state == .changed {
49
+            navBar.transitionAnimationWithPercent(percent)
50
+        }
51
+        
52
+        guard gestureRecognizer.state == .ended
53
+            || gestureRecognizer.state == .cancelled
54
+            || gestureRecognizer.state == .failed,
55
+            let coordinator = transitionCoordinator else { return }
56
+        
57
+        navBar.bounce = percent < 0.5 ? .backward : .forward
58
+        let durationPercent = Double(percent < 0.5 ? coordinator.percentComplete : (1 - coordinator.percentComplete))
59
+        UIView.animate(withDuration: coordinator.transitionDuration * durationPercent, delay: 0, usingSpringWithDamping: 1,
60
+                       initialSpringVelocity: coordinator.completionVelocity, options: [], animations: {
61
+            navBar.transitionAnimationWithPercent(1)
62
+        }) { _ in
63
+            navBar.clear()
64
+        }
65
+    }
13 66
 }
14 67
 
15
-//class NavigationController: UINavigationController {
16
-//
17
-//    override func viewDidLoad() {
18
-//        super.viewDidLoad()
19
-//
20
-//        // Do any additional setup after loading the view.
21
-//    }
22
-//    
23
-//    func set
24
-//}
25
-//
26
-//
27
-//extension UIViewController {
28
-//    n
29
-//}
68
+extension NavigationController: UINavigationControllerDelegate {
69
+    
70
+    public func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationController.Operation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
71
+        (navigationBar as? NavigationBar)?.isPush = operation == .push
72
+        return nil
73
+    }
74
+    
75
+    public func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
76
+        guard let navBar = navigationBar as? NavigationBar,
77
+            navBar.needsInteractive else { return }
78
+        
79
+        guard let coordinator = transitionCoordinator,
80
+            animated else {
81
+                navBar.setBackgroundImage()
82
+                navBar.clear()
83
+                return
84
+        }
85
+        
86
+        navBar.constructViewHierarchy()
87
+        
88
+        guard !coordinator.isInteractive else { return }
89
+        
90
+        coordinator.animate(alongsideTransition: { (transitionContext) in
91
+            DispatchQueue.main.async {
92
+                UIView.beginAnimations(nil, context: nil)
93
+                UIView.setAnimationCurve(transitionContext.completionCurve)
94
+                UIView.setAnimationDuration(transitionContext.transitionDuration)
95
+                navBar.transitionAnimation()
96
+                UIView.commitAnimations()
97
+            }
98
+        }, completion: { (transitionContext) in
99
+            navBar.clear()
100
+        })
101
+    }
102
+}
103
+
104
+extension NavigationController: UIGestureRecognizerDelegate {
105
+    public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
106
+        if gestureRecognizer == interactivePopGestureRecognizer {
107
+            return viewControllers.count > 1
108
+        }
109
+        return true
110
+    }
111
+}

+ 8 - 30
PaiAi/PaiaiUIKit/Reusable/UIKit/PageViewController/PageViewController.swift

@@ -72,7 +72,7 @@ open class PageViewController: UIViewController {
72 72
         constructViewHierarchy()
73 73
         activateConstraints()
74 74
         setMenuGestureRecognizer()
75
-        setupNavigationBarInteractivePopDelegate()
75
+        
76 76
     }
77 77
     
78 78
     open override func viewDidLayoutSubviews() {
@@ -90,8 +90,8 @@ open class PageViewController: UIViewController {
90 90
     }
91 91
     
92 92
     private func constructViewHierarchy() {
93
+        navigationItem.titleView = menuView
93 94
         view.addSubview(scrollView)
94
-        navigationController?.navigationBar.addSubview(menuView)
95 95
         menuView.addSubview(sliderView)
96 96
     }
97 97
 }
@@ -150,15 +150,12 @@ fileprivate extension PageViewController {
150 150
             
151 151
             let left: NSLayoutConstraint
152 152
             if let lastLabel = last {
153
-                left = label.leftAnchor
154
-                    .constraint(equalTo: lastLabel.rightAnchor, constant: option.spacing)
153
+                left = label.leftAnchor.constraint(equalTo: lastLabel.rightAnchor, constant: option.spacing)
155 154
             } else {
156
-                left = label.leadingAnchor
157
-                    .constraint(equalTo: menuView.leadingAnchor)
155
+                left = label.leadingAnchor.constraint(equalTo: menuView.leadingAnchor)
158 156
             }
159 157
             
160
-            let centerY = label.centerYAnchor
161
-                .constraint(equalTo: menuView.centerYAnchor)
158
+            let centerY = label.centerYAnchor.constraint(equalTo: menuView.centerYAnchor)
162 159
             
163 160
             if i == 0 {
164 161
                 label.textColor = option.selectedColor
@@ -178,17 +175,16 @@ fileprivate extension PageViewController {
178 175
     
179 176
     func setSliderViewDetail() {
180 177
         guard let label = menuView.viewWithTag(baseTag) else { return }
181
-        sliderConstraint = sliderView.centerXAnchor
182
-            .constraint(equalTo: label.centerXAnchor)
178
+        sliderConstraint = sliderView.centerXAnchor.constraint(equalTo: label.centerXAnchor)
183 179
         
184
-        NSLayoutConstraint.activate([sliderConstraint!])
180
+        NSLayoutConstraint.activate([sliderConstraint!,
181
+                                     sliderView.topAnchor.constraint(equalTo: label.bottomAnchor, constant: 6)])
185 182
     }
186 183
 }
187 184
 
188 185
 /// layout
189 186
 fileprivate extension PageViewController {
190 187
     func activateConstraints() {
191
-        activateConstraintsMenuView()
192 188
         activateConstraintsSliderView()
193 189
         activateConstraintsScrollView()
194 190
     }
@@ -206,18 +202,6 @@ fileprivate extension PageViewController {
206 202
         NSLayoutConstraint.activate([width, height, top, leading, bottom, trailing])
207 203
     }
208 204
     
209
-    func activateConstraintsMenuView() {
210
-        guard let barContentView = navigationController?.navigationBar else {  return }
211
-        
212
-        menuView.translatesAutoresizingMaskIntoConstraints = false
213
-        
214
-        NSLayoutConstraint.activate([
215
-            menuView.topAnchor.constraint(equalTo: barContentView.topAnchor),
216
-            menuView.bottomAnchor.constraint(equalTo: barContentView.bottomAnchor),
217
-            menuView.centerXAnchor.constraint(equalTo: barContentView.centerXAnchor)
218
-            ])
219
-    }
220
-    
221 205
     func activateConstraintsSliderView() {
222 206
         
223 207
         sliderView.translatesAutoresizingMaskIntoConstraints = false
@@ -366,9 +350,3 @@ fileprivate extension PageViewController {
366 350
         }
367 351
     }
368 352
 }
369
-
370
-extension PageViewController: NavigationBarInteractiveViewController {    
371
-    public var navigationView: UIView {
372
-        return menuView
373
-    }
374
-}

+ 0 - 1
PaiAi/Paiai_iOS/App/Group/GroupDetail/GroupNameModificationViewController.swift

@@ -86,5 +86,4 @@ extension GroupNameModificationViewController {
86 86
     }
87 87
 }
88 88
 
89
-
90 89
 extension GroupNameModificationViewController: NavigationBackViewController {}

+ 6 - 19
PaiAi/Paiai_iOS/App/Group/GroupViewController.swift

@@ -59,6 +59,7 @@ final class GroupViewController: UIViewController {
59 59
                                       bundle: Bundle(identifier: "com.Paiai-iOS")),
60 60
                                 forCellWithReuseIdentifier: "photoCell")
61 61
         setup()
62
+        setNavigationBar()
62 63
         binding()
63 64
     }
64 65
     
@@ -149,7 +150,7 @@ fileprivate extension GroupViewController {
149 150
     }
150 151
 }
151 152
 
152
-extension GroupViewController: NavigationBarInteractiveViewController {
153
+extension GroupViewController {
153 154
     var navigationView: UIView {
154 155
         return navigationBarView
155 156
     }
@@ -157,14 +158,13 @@ extension GroupViewController: NavigationBarInteractiveViewController {
157 158
     func setNavigationBar() {
158 159
         guard navigationViewNotReady else { return }
159 160
         setRightBarButtonItems()
160
-        construvtNaivgationViewHierarchy()
161
+        constructNaivgationViewHierarchy()
161 162
         activateConstraintsNavigation()
162
-        
163 163
         navigationViewNotReady = false
164 164
     }
165 165
     
166
-    private func construvtNaivgationViewHierarchy() {
167
-        navigationController?.navigationBar.addSubview(navigationBarView)
166
+    private func constructNaivgationViewHierarchy() {
167
+        navigationItem.titleView = navigationBarView
168 168
         navigationBarView.addSubview(navigationBarViewImage)
169 169
         navigationBarView.addSubview(navigationBarViewTitle)
170 170
     }
@@ -172,7 +172,7 @@ extension GroupViewController: NavigationBarInteractiveViewController {
172 172
     private func setRightBarButtonItems() {
173 173
         let item = UIBarButtonItem(images: [UIImage(named: "navigation-QR"),
174 174
                                             UIImage(named: "navigation-right")],
175
-                                   targets: [self, viewModel],
175
+                                   targets: [self, viewModel!],
176 176
                                    actions: [#selector(GroupViewController.presentGroupQR),
177 177
                                              #selector(GroupViewModel.navigateToGroupDetail)])
178 178
 
@@ -194,23 +194,10 @@ extension GroupViewController: NavigationBarInteractiveViewController {
194 194
 fileprivate extension GroupViewController {
195 195
     
196 196
     func activateConstraintsNavigation() {
197
-        activateConstraintsNavigationBarView()
198 197
         activateConstraintsNavigationBarViewImage()
199 198
         activateConstraintsNavigationBarViewTitle()
200 199
     }
201 200
     
202
-    func activateConstraintsNavigationBarView() {
203
-        guard let barContentView = navigationController?.navigationBar else {  return }
204
-        
205
-        navigationBarView.translatesAutoresizingMaskIntoConstraints = false
206
-        
207
-        NSLayoutConstraint.activate([
208
-            navigationBarView.topAnchor.constraint(equalTo: barContentView.topAnchor),
209
-            navigationBarView.bottomAnchor.constraint(equalTo: barContentView.bottomAnchor),
210
-            navigationBarView.centerXAnchor.constraint(equalTo: barContentView.centerXAnchor)
211
-            ])
212
-    }
213
-    
214 201
     func activateConstraintsNavigationBarViewTitle() {
215 202
         navigationBarViewTitle.translatesAutoresizingMaskIntoConstraints = false
216 203
         NSLayoutConstraint.activate([

+ 3 - 2
PaiAi/Paiai_iOS/App/Home/ScanQRViewController.swift

@@ -24,7 +24,8 @@ final class ScanQRViewController: UIViewController {
24 24
     override func viewDidLoad() {
25 25
         super.viewDidLoad()
26 26
         scanView.delegate = self
27
-        viewModel.join(code: "http://pai.ai/g/SpA5be3")
27
+//        viewModel.join(code: "http://pai.ai/g/SpA5be3")
28
+        setNavigationBar()
28 29
     }
29 30
     
30 31
     func setNavigationBar() {
@@ -34,7 +35,7 @@ final class ScanQRViewController: UIViewController {
34 35
     
35 36
     override func viewWillAppear(_ animated: Bool) {
36 37
         super.viewWillAppear(animated)
37
-        setNavigationBar()
38
+        
38 39
     }
39 40
 
40 41
     override func viewWillDisappear(_ animated: Bool) {

+ 1 - 14
PaiAi/Paiai_iOS/App/Message/MessageListViewController.swift

@@ -48,7 +48,7 @@ final class MessageListViewController: UIViewController {
48 48
         setup()
49 49
         binding()
50 50
         setNavigationBar()
51
-        self.viewModel.reload()
51
+        self.viewModel.reload()        
52 52
     }
53 53
     
54 54
     private func setNavigationBar() {
@@ -174,19 +174,6 @@ fileprivate extension MessageListViewController {
174 174
                     self.tableView.endRefreshing(at: .bottom)
175 175
                 }
176 176
             }).disposed(by: disposeBag)
177
-        
178
-        viewModel.hasMoreData
179
-            .asDriver(onErrorJustReturn: true)
180
-            .drive(onNext: {[weak self] flag in
181
-                guard let `self` = self else { return }
182
-                if flag {
183
-                    if self.tableView.bottomPullToRefresh == nil {
184
-                        self.setupLoadingControl()
185
-                    }
186
-                } else {
187
-//                    self.tableViewt
188
-                }
189
-            }).disposed(by: disposeBag)
190 177
     }
191 178
 }
192 179
 

+ 0 - 13
PaiAi/Paiai_iOS/App/Mine/MineGroupViewController.swift

@@ -128,19 +128,6 @@ fileprivate extension MineGroupViewController {
128 128
                     self.tableView.endRefreshing(at: .bottom)
129 129
                 }
130 130
             }).disposed(by: disposeBag)
131
-        
132
-        viewModel.hasMoreData
133
-            .asDriver(onErrorJustReturn: true)
134
-            .drive(onNext: {[weak self] flag in
135
-                guard let `self` = self else { return }
136
-                if flag {
137
-                    if self.tableView.bottomPullToRefresh == nil {
138
-                        self.setupLoadingControl()
139
-                    }
140
-                } else {
141
-                    //                    self.tableViewt
142
-                }
143
-            }).disposed(by: disposeBag)
144 131
     }
145 132
 }
146 133
 

+ 0 - 13
PaiAi/Paiai_iOS/App/Mine/MineOrderViewController.swift

@@ -111,19 +111,6 @@ fileprivate extension MineOrderViewController {
111 111
                     self.tableView.endRefreshing(at: .bottom)
112 112
                 }
113 113
             }).disposed(by: disposeBag)
114
-        
115
-        viewModel.hasMoreData
116
-            .asDriver(onErrorJustReturn: true)
117
-            .drive(onNext: {[weak self] flag in
118
-                guard let `self` = self else { return }
119
-                if flag {
120
-                    if self.tableView.bottomPullToRefresh == nil {
121
-                        self.setupLoadingControl()
122
-                    }
123
-                } else {
124
-                    //                    self.tableViewt
125
-                }
126
-            }).disposed(by: disposeBag)
127 114
     }
128 115
 }
129 116
 

fix bug: operator_name decode · 33468847a7 - Gogs: Go Git Service

fix bug: operator_name decode

FFIB 4 years ago
parent
commit
33468847a7
1 changed files with 1 additions and 1 deletions
  1. 1 1
      logs/models.py

+ 1 - 1
logs/models.py

@@ -44,7 +44,7 @@ class MchInfoEncryptLogInfo(BaseModelMixin):
44 44
         try:
45 45
             operator_name = OperatorInfo.objects.get(operator_id=self.operator_id).name
46 46
         except OperatorInfo.DoesNotExist:
47
-            operator_name = '深圳捷成'
47
+            operator_name = u'深圳捷成'
48 48
 
49 49
         return {
50 50
             'sn': self.sn,